import {
  getContrastList
} from "@/api/wxauto";

export default {
  state: {
    userList: [],   //联系人信息
    groupList: [],  //群组信息
    ghList: [],     //公众号信息   
  },
  mutations: {
    async initInfo(state) {
      const contrastList = (await getContrastList()).filter(item => item.nickname);
      const userList = [];
      const groupList = [];
      const ghList = [];

      contrastList.forEach((item) => {
        if (item.type === 2) {
          groupList.push(item);
        } else {
          if (item.wxid.startsWith("gh_") || item.encryptName === '') {
            ghList.push(item)
          } else {
            userList.push(item);
          }
        }
      });
      state.userList = userList
      state.groupList = groupList
      state.ghList = ghList
    },
  },
};
